﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

using ReadSSCInfo;
namespace JsRunTool
{
    public struct ThreadParamter
    {
        public Form1 formArgs;  //可以加其它变量
        public CardDllInterface cardDll;
    }

    class MyThread
    {
        private ThreadParamter threadParamter;
        private Thread thread;

        public MyThread(ThreadParamter _threadParamter)
        {
            threadParamter = _threadParamter;
            thread = new Thread(new ThreadStart(Run));
            thread.Name = "MyThread";
            Control.CheckForIllegalCrossThreadCalls = false;
            thread.IsBackground = true; 
        }

        public void Start()
        {
            if (thread != null)
            {
                thread.Start();
            }
        }

        public void Run()
        {
            //Script sc = new Script();
            bool flag = threadParamter.cardDll.runJs(threadParamter.formArgs.m_jsPath);
            if (flag)
            {
                threadParamter.formArgs.showInfo("成功!");
            }
            else
            {
                threadParamter.formArgs.showInfo("失败!");
            }
        }
    }
}
